package com.wondersgroup.framework.sample.component.grid.action;

import com.wondersgroup.framework.core.bo.Page;
import com.wondersgroup.framework.core.exception.BusinessException;
import com.wondersgroup.framework.core.web.struts2.action.BaseExcelAction;
import com.wondersgroup.framework.core.web.vo.VOUtils;
import com.wondersgroup.framework.sample.component.data.GridData;
import com.wondersgroup.framework.sample.component.grid.vo.GridVO;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;

public class GridAction extends BaseExcelAction
{
  public String query()
  {
    int start = 0;
    int size = 10;
    String pStart = this.servletRequest.getParameter("start");
    String pSize = this.servletRequest.getParameter("limit");
    if (pStart != null)
      start = Integer.parseInt(pStart);

    if (pSize != null) {
      size = Integer.parseInt(pSize);
    }

    Page page = new GridData(this.servletRequest).getPage(start, size);
    String json = VOUtils.getJsonDataFromPage(page, GridVO.class);

    this.logger.info("this is grid action: " + json);
    createJSonData(json);
    return "ajax";
  }

  public String queryError()
  {
    throw new BusinessException("莫名的错误!");
  }

  public List getExportDataList()
  {
    return null;
  }

  public Object getExportSummaryData()
  {
    return null;
  }
}